package com.zx.wangyixinwen.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.zx.wangyixinwen.MyRequestQueue;
import com.zx.wangyixinwen.R;
import com.zx.wangyixinwen.bean.Topic;
import com.zx.wangyixinwen.bean.TopicBean;

import java.util.List;

import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;

/**
 * Created by dllo on 16/1/21.
 */
public class TopicActivity extends Activity implements View.OnClickListener {
    private List<Topic> datas;
    private List<TopicBean> data;
    private ImageView fanhui, fenxiang;
    private NetworkImageView background, headimage;
    private TextView alias, name, title, description;

    private static int pos;
    private static Context context;
    private static Topic.DataEntity.ExpertListEntity bean;

    public static void goToTopic(Context context, Topic.DataEntity.ExpertListEntity bean) {
        TopicActivity.context = context;
        TopicActivity.bean = bean;
        TopicActivity.pos = pos;
        Intent intent = new Intent(context, TopicActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_topic);
        findViewById(R.id.iv_return).setOnClickListener(this);
        findViewById(R.id.iv_fenxiang).setOnClickListener(this);
        background = (NetworkImageView) findViewById(R.id.iv_topic_background);
        headimage = (NetworkImageView) findViewById(R.id.iv_topic_headtu);
        alias = (TextView) findViewById(R.id.tv_topic_alias);
        name = (TextView) findViewById(R.id.topic_name);
        title = (TextView) findViewById(R.id.topic_title);
        description = (TextView) findViewById(R.id.topic_body);
        MyRequestQueue.setNetImage(background, bean.getPicurl());
        MyRequestQueue.setNetImage(headimage, bean.getHeadpicurl());
        alias.setText(bean.getAlias());
        name.setText(bean.getName());
        title.setText(bean.getTitle());
        description.setText(bean.getDescription());

    }

//    private int getPosition() {
//        Bundle bundle = getIntent().getBundleExtra("bundle");
//        return Integer.parseInt(bundle.getString("topic"));
//    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_return:
                finish();
                break;
            case R.id.iv_fenxiang:
                showShare();
                break;
        }

    }
    private void showShare() {
        ShareSDK.initSDK(this);
        OnekeyShare oks = new OnekeyShare();
        //关闭sso授权
        oks.disableSSOWhenAuthorize();

// 分享时Notification的图标和文字  2.5.9以后的版本不调用此方法
        //oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
        // title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间使用
        oks.setTitle("HMN");
        // titleUrl是标题的网络链接，仅在人人网和QQ空间使用
        oks.setTitleUrl("http://sharesdk.cn");
        // text是分享文本，所有平台都需要这个字段
        oks.setText("我是分享文本");
        // imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
        oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
        // url仅在微信（包括好友和朋友圈）中使用
        oks.setUrl("http://sharesdk.cn");
        // comment是我对这条分享的评论，仅在人人网和QQ空间使用
        oks.setComment("我是测试评论文本");
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite(getString(R.string.app_name));
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl("http://sharesdk.cn");

// 启动分享GUI
        oks.show(this);
    }

}
